#ifndef __CHAINOFRESPONSIBILITY_H__
#define __CHAINOFRESPONSIBILITY_H__
#include <iostream>

/// @brief 管理者基类
class COPManager
{
protected:
    COPManager *m_pSuperior{};
    std::string m_name;

public:
    COPManager(const std::string &name)
        : m_name(name) {}
    /// @brief 设置上级
    /// @param pSuperior 上级管理者指针
    void SetSuperior(COPManager *pSuperior)
    {
        m_pSuperior = pSuperior;
    }
    /// @brief 处理申请
    virtual void HandleApplication(const std::string &type, int number) = 0;
};
/// @brief 组长
class COPTeamLeader : public COPManager
{
public:
    COPTeamLeader(const std::string &name)
        : COPManager(name) {}
    virtual void HandleApplication(const std::string &type, int number) override
    {
        if (type == "加薪" && number <= 500)
        {
            std::cout << m_name << "：好的给你加" << number << std::endl;
        }
        else if (m_pSuperior)
        {
            m_pSuperior->HandleApplication(type, number);
        }
    }
};
/// @brief 总监
class COPDirector : public COPManager
{
public:
    COPDirector(const std::string &name)
        : COPManager(name) {}
    virtual void HandleApplication(const std::string &type, int number) override
    {
        if (type == "加薪" && number <= 1500)
        {
            std::cout << m_name << "：好的给你加" << number << std::endl;
        }
        else if (m_pSuperior)
        {
            m_pSuperior->HandleApplication(type, number);
        }
    }
};
/// @brief 董事长
class COPChairman : public COPManager
{
public:
    COPChairman(const std::string &name)
        : COPManager(name) {}
    virtual void HandleApplication(const std::string &type, int number) override
    {
        if (type == "加薪")
        {
            if (number <= 2000)
            {
                std::cout << m_name << "：好的给你加" << number << std::endl;
            }
            else
            {
                std::cout << m_name << "：再说吧" << std::endl;
            }
        }
    }
};

#endif